#include "CCompressPlugin.h"
extern "C"
{
#include "zlib/zlib.h"
	int ZEXPORT compress (
		Bytef *dest,
	uLongf *destLen,
	const Bytef *source,
	uLong sourceLen);

	int ZEXPORT uncompress (
		Bytef *dest,
	uLongf *destLen,
	const Bytef *source,
	uLong sourceLen);
};


PLUGIN_API bool Compress(const void* pSrcData, size_t szSrc, void* pDestData, size_t stDest, size_t& szResult)
{
	szResult = 0;
	uLongf n = stDest;
	if (0 == compress((Bytef*)pDestData, &n, (Bytef*)pSrcData, szSrc))
		szResult = n;
	return szResult > 0;
}

PLUGIN_API bool unCompress(const void* pSrcData, size_t szSrc, void* pDestData, size_t stDest, size_t& szResult)
{
	szResult = 0;
	uLongf n =stDest;
	if (0 == uncompress((Bytef*)pDestData, &n, (Bytef*)pSrcData, szSrc))
		szResult = n;

	return szResult > 0;
}

PLUGIN_API char* GetPluginName()
{
	return "ZIP";
}